jQuery(document).ready(function($) {
   $(".synch_tablelist td a.changeaccount").click(function(){
      var target = $(this);
      // disable all open account change window 
      $(".hr_accountchange").hide(); 
      // show myself 
      $("#"+target.attr('rel')).show().position({
        my:"left top+10",
        at:"left-60 bottom",
        of:target,
        collision:"none"
      });

      return false; 
   });
   
   $("#51job_form, #zhilian_form, #lagou_form, #jiancai_form").on('click', "input[name=rememberme]", function() {
      if($(this).prop('checked')) {
         $(this).closest('form').find("input[type=password]").addClass("required");
      }
      else {
         $(this).closest('form').find("input[type=password]").removeClass("required");   
      }
   })
 
   var validator = {
      submitHandler: function(form) {
        $(form).ajaxSubmit({
         dataType: "json",
         beforeSubmit: function(data, form, options) {
            if(!showLoading(form))
               return false;
          },
          success: function(data) {
            try {
               if(data.error) { 
                  $(form).children('.systemerror').show().html(data.error);
               }else if(data.success){
                  $(form).parent().fadeOut();
                  window.location.reload(true);
               }
            } catch(e) {
               return false;
            }
         }
       });
      }
   };
   
   $("#51job_form").validate(validator);
   $("#zhilian_form").validate(validator);
   $("#jiancai_form").validate(validator);
   $("#lagou_form").validate(validator);
});
